package cn.ustb.dao;

import cn.ustb.entity.LevelExam;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface LevelExamDao {
    @Select("select * from levelExam")
    List<LevelExam> getAll();

    @Select({"<script>",
            "select * from levelExam where courseId = #{courseId} and yearTerm = #{yearTerm}",
            "<if test = \"yearTerm!=null\">"+
                    " and yearTerm = #{yearTerm}"+
                    " </if>",
            "</script>"
    })
    LevelExam get(@Param("courseId") String courseId, @Param("yearTerm") String yearTerm);

    @Insert("insert into levelExam values(#{yearTerm},#{courseId},#{courseName},#{applyTime},#{examTime},#{examCost})")
    void insert(LevelExam levelExam);

    @Update("update levelExam set YearTerm = #{yearTerm},CourseName = #{courseName}, ApplyTime = #{applyTime}, ExamTime = #{examTime}, ExamCost = #{examCost} where courseId = #{courseId}")
    void update(LevelExam levelExam);

    @Delete("delete from levelExam where courseId = #{courseId}")
    void delete(String courseId);

    @Select("select * from levelExam where yearTerm = #{yearTerm}")
    List<LevelExam> getAllWithYearTerm(String yearTerm);
}
